
file(GLOB_RECURSE utCode 
    ${CMAKE_CURRENT_SOURCE_DIR}/unity/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/dev_test/${PROJECTNAME}/*.c
)
set(TEST_BIN_TARGET ${PROJECT_NAME}_test)
add_executable(${TEST_BIN_TARGET}.elf
    EXCLUDE_FROM_ALL
    ${src} ${LINKER_SCRIPT} ${utCode})
target_link_libraries(
    ${TEST_BIN_TARGET}.elf PRIVATE
    ${staticLibGroup}
)
target_include_directories(
    ${TEST_BIN_TARGET}.elf PRIVATE
    ${PROJECT_SOURCE_DIR}/Project/${PROJECTNAME}/app/inc
    ${PROJECT_SOURCE_DIR}/Project/${PROJECTNAME}/dev/inc
    ${PROJECT_SOURCE_DIR}/Project/${PROJECTNAME}/drv/inc
    ${PROJECT_SOURCE_DIR}/UnityTest/unity
)

set(HEX_FILE ${PROJECT_BINARY_DIR}/${TEST_BIN_TARGET}.hex)
set(BIN_FILE ${PROJECT_BINARY_DIR}/${TEST_BIN_TARGET}.bin)

add_custom_command(TARGET ${TEST_BIN_TARGET}.elf POST_BUILD
        COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${TEST_BIN_TARGET}.elf> ${HEX_FILE}
        COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${TEST_BIN_TARGET}.elf> ${BIN_FILE}
        COMMENT "Building ${HEX_FILE}
Building ${BIN_FILE}")
